﻿using System.Text.Json.Serialization;

namespace System.Text.Json;

public class DictionaryJsonConvert : JsonConverter<Dictionary<string, object>>
{
    public override Dictionary<string, object> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        throw new NotImplementedException();
    }

    public override void Write(Utf8JsonWriter writer, Dictionary<string, object> value, JsonSerializerOptions options)
    {
        writer.WriteStartObject(); 
        foreach (var kvp in value)
        {
            writer.WritePropertyName(kvp.Key);  
            JsonSerializer.Serialize(writer, kvp.Value, options);  
        }
        writer.WriteEndObject();  
    }
}

